/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

typedef long long ll;

constexpr int maxn = 5e3 + 5, mod = 1e9 + 7;

int inv[maxn], facinv[maxn];

int p[maxn], y[maxn];

int pre[maxn], suf[maxn];

int lagrange(int n, int x) {
  ll res = 0;
  pre[0] = suf[n + 2] = 1;
  for (int i = 1; i <= n + 1; ++i) pre[i] = (ll)pre[i - 1] * (x - i) % mod;
  for (int i = n + 1; i >= 1; --i) suf[i] = (ll)suf[i + 1] * (x - i) % mod;
  for (int i = 1; i <= n + 1; ++i) {
    ll mul = ((ll)pre[i - 1] * suf[i + 1] % mod + mod) % mod;
    ll div = (ll)facinv[i - 1] * facinv[n + 1 - i] % mod;
    ll sig = (n + 1 - i) & 1 ? -1 : 1;
    res += mul * (mod + sig) % mod * div % mod * y[i] % mod;
    res %= mod;
  }
  return res;
}

int main() {
  int n, r;
  cin >> n >> r;
  inv[1] = facinv[1] = facinv[0] = 1;
  for (int i = 2; i < maxn; i++) {
    inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
    facinv[i] = (ll)facinv[i - 1] * inv[i] % mod;
  }
  for (int i = 1; i <= n; ++i) cin >> p[i];
  int max = 0;
  for (int i = n; i >= 1; i--) {
    max = std::max(max, p[i]);
    p[i] = max;
  }
  if (max > r) {
    cout << "0\n";
    return 0;
  }
  for (int i = 1; i <= n + 1; ++i) y[i] = 1;
  for (int i = n; i >= 1; --i) {
    for (int j = 2; j <= n + 1; ++j) y[j] = (y[j - 1] + y[j]) % mod;
    int res = lagrange(n - i + 1, p[i] - 1);
    for (int j = 1; j <= n + 1; ++j) y[j] = (y[j] - res + mod) % mod;
  }
  cout << lagrange(n, r) << '\n';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("C. Assigning Prizes.in", "r", stdin);
  freopen("C. Assigning Prizes.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
